package opera;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 言初
 * Date: 2023-01-09
 * Time: 10:12
 * 查找，我们可以根据书名来进行查找
 */
public class FindOperation implements IOPeration{
    public void work(BookList bookList){
        System.out.println("查找图书");
        System.out.println("请输入你想要查找的图书的名字：");
        Scanner sc=new Scanner(System.in);
        String name=sc.nextLine();
        sc.close();

        int currentSize=bookList.getUsedSize();
        for(int i=0;i<currentSize;i++){
            Book book=bookList.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("找到了这本书");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到这本书");
    }

}
